<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:fragment="common_head">
    <meta charset="utf-8">
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1" name="viewport">
    <link rel="stylesheet" th:href="@{/admin/assets/css/bootstrap-clearmin.min.css}" type="text/css">
    <link rel="stylesheet" th:href="@{/admin/assets/css/roboto.css}" type="text/css">
    <link rel="stylesheet" th:href="@{/admin/assets/css/material-design.css}" type="text/css">
    <link rel="stylesheet" th:href="@{/admin/assets/css/small-n-flat.css}" type="text/css">
    <link rel="stylesheet" th:href="@{/admin/assets/css/font-awesome.min.css}" type="text/css">
</head>
<body>
<!--后台公共侧边栏-->
<div id="cm-menu" th:fragment="common_siderbar">
    <nav class="cm-navbar cm-navbar-primary">
        <div class="cm-flex"><a class="cm-logo" th:href="@{/admin/index}"></a></div>
        <div class="btn btn-primary md-menu-white" data-toggle="cm-menu"></div>
    </nav>
    <div id="cm-menu-content">
        <div id="cm-menu-items-wrapper">
            <div id="cm-menu-scroller">
                <ul class="cm-menu-items">
                    <li th:class="(@{/admin/index} eq ${#request.requestURI} ? 'active')">
                        <a class="sf-house" th:href="@{/admin/index}">Home</a>
                    </li>
                    <li class="cm-submenu"
                        th:classappend="${#strings.contains(#request.requestURI,'/erb/admin/product')} ? 'open'">
                        <a class="sf-building">投资项目<span class="caret"></span></a>
                        <ul>
                            <!--<li th:class="(@{/admin/product-type/list} eq ${#request.requestURI} ? 'active')">
                                <a th:href="@{/admin/product-type/list}">项目类型</a>
                            </li>-->
                            <li th:class="(@{/admin/product/list} eq ${#request.requestURI} ? 'active')">
                                <a th:href="@{/admin/product/list}">项目列表</a>
                            </li>
                        </ul>
                    </li>
                    <li class="cm-submenu"
                        th:classappend="${#strings.contains(#request.requestURI,'/erb/admin/user')} ? 'open'">
                        <a class="sf-building">用户管理<span class="caret"></span></a>
                        <ul>
                            <li th:class="(@{/admin/user/list} eq ${#request.requestURI} ? 'active')">
                                <a th:href="@{/admin/user/list}">用户列表</a>
                            </li>
                        </ul>
                    </li>
                    <li class="cm-submenu"
                        th:classappend="${#strings.contains(#request.requestURI,'/erb/admin/redpacket')} ? 'open'">
                        <a class="sf-building">红包管理<span class="caret"></span></a>
                        <ul>
                            <li th:class="(@{/admin/redpacket/list} eq ${#request.requestURI} ? 'active')">
                                <a th:href="@{/admin/redpacket/list}">红包列表</a>
                            </li>
                        </ul>
                    </li>
                    <li class="cm-submenu"
                        th:classappend="${#strings.contains(#request.requestURI,'/erb/admin/advertisement')} ? 'open'">
                        <a class="sf-building">广告管理<span class="caret"></span></a>
                        <ul>
                            <li th:class="(@{/admin/advertisement/adver-list} eq ${#request.requestURI} ? 'active')">
                                <a th:href="@{/admin/advertisement/adver-list}">首页轮播图管理</a>
                            </li>
                            <li th:class="(@{/admin/advertisement/notice-list} eq ${#request.requestURI} ? 'active')">
                                <a th:href="@{/admin/advertisement/notice-list}">公告管理</a>
                            </li>
                        </ul>
                    </li>
                    <li class="cm-submenu"
                        th:classappend="${#strings.contains(#request.requestURI,'/erb/admin/integral-goods')} ? 'open'">
                        <a class="sf-building">积分商城<span class="caret"></span></a>
                        <ul>
                            <li th:class="(@{/admin/integral-goods/list} eq ${#request.requestURI} ? 'active')">
                                <a th:href="@{/admin/integral-goods/list}">商品列表</a>
                            </li>
                        </ul>
                    </li>
                    <li class="cm-submenu"
                        th:classappend="${#strings.contains(#request.requestURI,'/erb/loan/back')} ? 'open'">
                        <a class="sf-magnify">贷款管理<span class="caret"></span></a>
                        <ul>
                            <li th:class="(@{/loan/back-loanapplu} eq ${#request.requestURI} ? 'active')">
                                <a th:href="@{/loan/back-loanapplu}">申请</a>
                            </li>
                            <li th:class="(@{/loan/back-make/makelist} eq ${#request.requestURI} ? 'active')">
                                <a th:href="@{/loan/back-make//makelist}">贷款金额</a>
                            </li>
                            <li th:class="(@{/loan/back-audit/list} eq ${#request.requestURI} ? 'active')">
                                <a th:href="@{/loan/back-audit/list}">后台审核</a>
                            </li>
                            <li th:class="(@{/loan/back-make/tolimit} eq ${#request.requestURI} ? 'active')">
                                <a th:href="@{/loan/back-make/tolimit}">评估金额</a>
                            </li>
                        </ul>
                    </li>
                    <!--二级菜单-->
                    <!--<li class="cm-submenu">
                        <a class="sf-cat">Icons <span class="caret"></span></a>
                        <ul>
                            <li><a th:href="@{/ico-sf.html}">Small-n-flat</a></li>
                            <li><a th:href="@{/ico-md.html}">Material Design</a></li>
                            <li><a th:href="@{/ico-fa.html}">Font Awesome</a></li>
                        </ul>
                    </li>-->
                </ul>
            </div>
        </div>
    </div>
</div>
<!--后台公共顶部-->
<header id="cm-header" th:fragment="common_top">
    <script type="text/javascript">
        function exit(url) {
            layer.confirm('确定要退出吗？', {title: '确认退出'}, function (i) {
                location.href = url;
            });
        }
    </script>
    <nav class="cm-navbar cm-navbar-primary">
        <div class="btn btn-primary md-menu-white hidden-md hidden-lg" data-toggle="cm-menu"></div>
        <div class="cm-flex">
            <h1>Home</h1>
            <form action="index.html" id="cm-search" method="get">
                <input autocomplete="off" name="q" placeholder="Search..." type="search">
            </form>
        </div>
        <!--<div class="pull-right">
            <div class="btn btn-primary md-search-white" data-toggle="cm-search" id="cm-search-btn"></div>
        </div>-->
        <div class="dropdown pull-right" id="inform-box">
            <button class="btn btn-primary md-notifications-white" data-toggle="dropdown">
                <span class="label label-danger" id="inform-count" style="display: none">23</span>
            </button>
            <div class="popover cm-popover bottom">
                <div class="arrow"></div>
                <div class="popover-content">
                    <div class="list-group" id="inform-list">
                        <!--<a class="list-group-item" th:href="@{/}">
                            <h4 class="list-group-item-heading text-overflow">
                                <i class="fa fa-fw fa-envelope"></i> Nunc volutpat aliquet magna.
                            </h4>
                        </a>-->
                    </div>
                    <div style="padding:10px"><a class="btn btn-success btn-block" href="javascript:" id="showInforms">查看所有</a></div>
                </div>
            </div>
        </div>
        <div class="dropdown pull-right">
            <button class="btn btn-primary md-account-circle-white" data-toggle="dropdown"></button>
            <ul class="dropdown-menu">
                <li class="disabled text-center">
                    <a style="cursor:default;"><strong th:text="(null ne ${session.admin} ? ${session.admin.name})"></strong></a>
                </li>
                <li class="divider"></li>
                <!--<li>
                    <a th:href="@{/}"><i class="fa fa-fw fa-user"></i> Profile</a>
                </li>
                <li>
                    <a th:href="@{/}"><i class="fa fa-fw fa-cog"></i> Settings</a>
                </li>-->
                <li>
                    <a id="exit-btn" th:href="|javascript:exit('@{/admin/exit}');|"><i class="fa fa-fw fa-sign-out"></i>退出登录</a>
                </li>
            </ul>
        </div>
    </nav>
</header>

<footer class="cm-footer" th:fragment="common_footer">
    <span class="pull-left">Connected as John Smith</span>
    <span class="pull-right">&copy; PAOMEDIA SARL</span>
</footer>

<footer th:fragment="common_footer_script" th:remove="tag">
    <script th:src="@{/admin/assets/js/lib/jquery.min.js}"></script>
    <script th:src="@{/admin/assets/js/jquery.mousewheel.min.js}"></script>
    <script th:src="@{/admin/assets/js/jquery.cookie.min.js}"></script>
    <script th:src="@{/admin/assets/js/fastclick.min.js}"></script>
    <script th:src="@{/admin/assets/js/bootstrap.min.js}"></script>
    <script th:src="@{/admin/assets/js/clearmin.min.js}"></script>
    <script th:src="@{/admin/assets/layer/layer.js}"></script>
    <script th:src="@{/admin/assets/js/common.js}"></script>
    <script th:if="(null ne ${session.admin})" type="text/javascript">
        // 刷新通知列表
        function refreshInformList() {
            $.getJSON('[[@{/admin/inform/findUnreadInforms}]]', {recipientsId: 0}, function (data) {
                // 更新总数
                let $informCountBox = $('#inform-count');
                if (data.obj.unreadInformCount > 0) {
                    $informCountBox.show().text(data.obj.unreadInformCount).show();
                } else {
                    $informCountBox.hide();
                }

                // 更新列表
                let unreadList = data.obj.unreadInformList, $informBox = $('#inform-list');
                // inform-count
                let str = '';
                for (let i = 0; i < unreadList.length; i++) {
                    str += '<a class="list-group-item" href="javascript:loadingInformDetail(' + unreadList[i].informId + ');" title="点击查看">';
                    str += '<h4 class="list-group-item-heading text-overflow" style="font-weight: unset;">';
                    str += '<i class="fa fa-fw fa-envelope"></i>&ensp;<b>' + unreadList[i].informSenderName + '</b>给您发了一条通知【<b>' + unreadList[i].informTitle +
                        '</b>】';
                    str += '</h4>';
                    str += '</a>';
                }
                $informBox.html(str);
            });
        }

        // 读取通知详细
        function loadingInformDetail(informId) {
            let loadIndex = layer.load();

            $.getJSON('[[@{/admin/inform/readInformDetail}]]', {informId: informId}, function (data) {
                refreshInformList();
                layer.close(loadIndex);

                if (data.obj !== null) {
                    let o = data.obj;
                    layer.open({
                        type: 1,
                        skin: 'layui-layer-rim', //加上边框
                        area: ['420px', '240px'], //宽高
                        title: '通知：',
                        content: '<div style="padding: 10px;">' + o.informContent + '</div>'
                    });
                } else {
                    layer.msg(data.msg);
                }
            })
        }

        $(function () {
            refreshInformList();
            setInterval(function () {
                refreshInformList();
            }, 10000);

            $('#showInforms').on('click', function (event) {
                layer.open({
                    id: 'informs-layer',
                    type: 2,
                    title: '全部通知',
                    content: '[[@{/admin/inform/findInforms}]]',
                    area: ['800px', '600px'],
                    scrollbar: false,
                    resize: true
                });
            })
        })
    </script>
</footer>
</body>
</html>